home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
dump_s1r
/
common.bas
< prev
next >
Wrap
BASIC Source File
|
1998-12-19
|
4KB
|
106 lines
Attribute VB_Name = "modCommonProcs"
Option Explicit
'-------------------------------------------------'
'This Checks a File to see if it exists or not '
'-------------------------------------------------'
Public Function CheckFile(Path As String) As Boolean
CheckFile = True 'Assume Success
On Error Resume Next
Dim Disregard As Long
Disregard = FileLen(Path)
If Err <> 0 Then CheckFile = False
End Function
'-------------------------------------------------'
'This Checks a path to see if it exists or not. '
'-------------------------------------------------'
Public Property Get CheckPath(Path As String) As Boolean
CheckPath = True 'Assume Success
On Error Resume Next
ChDir Path
If Err <> 0 Then CheckPath = False
End Property
'-------------------------------------------------'
'This is used in case you want to open a file '
'with the 'Binary' Option without having the old '
'Data There(m_lngLoop Know it is possible to kill it but '
'This checks for validity first.) '
'-------------------------------------------------'
Public Function MakeFileEmpty(Path As String) As Boolean
Dim FreeFile
If Not CheckFile(Path) Then _
MakeFileEmpty = False _
: Exit Function
On Error Resume Next
Open Path For Output As #1
If Err <> 0 Then _
MakeFileEmpty = False _
: Exit Function
Close #1
End Function
'-------------------------------------------------'
'This Procedure Was Wrote To Return a Filename '
'Without Having to use The 'If' Statment in the '
'Procedures that need the correct Filename '
'Returned '
'-------------------------------------------------'
Public Function MakeFileName(FileName As String, Path As String) As String
Dim strBckSlash$
If Not Right(Path, 1) = "\" Then
strBckSlash$ = "\"
End If
MakeFileName = Path$ & strBckSlash & FileName
End Function
Public Function CheckString(Collection As Collection, Text) As Boolean
Dim m_lngLoop As Long
For m_lngLoop = 1 To Collection.Count
If LCase(Collection(m_lngLoop)) = LCase(Text) Then CheckString = True
Next
End Function
Public Sub EndApp()
Dim Form As Form
For Each Form In Forms
Unload Form
Next
End Sub
Public Sub DoUntilNotVisible(Form As Form)
Form.Show 0
Do Until Not Form.Visible
DoEvents
Loop
End Sub
Public Function GetMatchCount(ByVal Text As String, ByVal Search4 As String) As Long
Dim cnt As Long, m_lngLoop As Long
For m_lngLoop = 1 To Len(Text)
If Mid(Text, m_lngLoop, Len(Search4)) = Search4 Then
cnt = cnt + 1
End If
Next
GetMatchCount& = cnt
End Function
Public Function WrapText(ByVal Text As String, ByVal WrapLength As Single, ByVal TextWidFunctObj As Object) As String
Dim txtObj As Object, sText As String, m_lngLoop As Long, OutText As String
Dim TP1 As Long, TP2 As Long 'Text Location Variables.
sText = Text
TP1 = 1
Set txtObj = TextWidFunctObj
For m_lngLoop = 1 To Len(Text)
TP2 = TP2 + 1
If txtObj.TextWidth(Mid(sText, TP1, TP2)) >= WrapLength Then
OutText = OutText & Mid(sText, TP1, TP2) & vbCrLf
TP1 = m_lngLoop
TP2 = 0
End If
Next
OutText = OutText & Mid(sText, TP1)
WrapText = OutText
End Function